package com.ld.security.server.admin.modules.gl.po;

import com.ld.security.common.core.base.SuperPo;
import com.ld.security.common.mybatis.anno.QueryKey;
import com.ld.security.common.mybatis.anno.RemoveKey;
import com.ld.security.common.mybatis.anno.SaveKey;
import com.ld.security.server.admin.modules.gl.entity.GlEnumEntity;
import com.ld.security.server.admin.modules.gl.entity.GlEnumItemEntity;
import lombok.Data;

import java.util.LinkedList;
import java.util.List;

@Data
public class EnumSavePo implements SuperPo {


    @SaveKey
    @RemoveKey
    private GlEnumEntity parent;

    @RemoveKey
    @SaveKey(name = "enumId",valueField = "parent.id")

    @QueryKey
    private List<GlEnumItemEntity> children;


    public EnumSavePo addChildren(GlEnumItemEntity e){
        if(children == null){
            children = new LinkedList<>();
        }
        children.add(e);
        return this;
    }
}
